@extends('manage.layout')
@section('link')
    <style>
        ul,li,ol{
            list-style-type: none;
        }
        .setul li{
            float: left;
            margin:0 15px 0 0;
        }
    </style>
@stop
@section('content')
    <section class="content-header">
        <h1>
            案例列表
        </h1>
        <ol class="breadcrumb">
            <li><a href="#"><i class="fa fa-dashboard"></i> Home</a></li>
            <li><a href="#">Case</a></li>
            <li class="active">Case List</li>
        </ol>
        {{--<div class="input-group margin">--}}
            {{--<form action="{{ url('caseList') }}" method="get">--}}
                {{--{{ csrf_field() }}--}}
                {{--<select style="width: 150px" id="sel"  name="searchtype" class="form-control" onchange="select()">--}}
                    {{--@foreach($searchtype as $value)--}}
                        {{--<option value="{{ $value['id'] }}">{{ $value['searchtype'] }}</option>--}}
                    {{--@endforeach--}}
                {{--</select>--}}

                {{--<div style="float: left" id="form">--}}
                    {{--<input id="datepicker" style="width: 200px"  name="param" type="text" class="form-control">--}}
                    {{--<input style="width: 200px" type="text" name="param" class="form-control" id="datepicker">--}}
                {{--</div>--}}
                {{--<input  type="submit" class="btn btn-info btn-flat" value="Go!">--}}
            {{--</form>--}}
            {{--<script>--}}
                {{--function select() {--}}
                    {{--var val = $('#sel option:selected').val();--}}
                    {{--console.log(val);--}}
                    {{--if(val == 2) {--}}
                        {{--$('#datepicker').datepicker({--}}
                            {{--autoclose: true,--}}
                            {{--format: 'yyyy-mm-dd'--}}
                        {{--});--}}
                    {{--}--}}
                    {{--else if(val == 11) {--}}
                        {{--$('#datepicker').datepicker({--}}
                            {{--autoclose: true,--}}
                            {{--format: 'yyyy-mm-dd'--}}
                        {{--});--}}
                    {{--}--}}
                    {{--else{--}}
                        {{--$('#datepicker').datepicker('remove');--}}
{{--//                        $('#datepicker').datepicker('remove');--}}
{{--//                        $('#form').html('<input style="width: 200px" id="data" name="param" type="text" class="form-control">');--}}
                    {{--}--}}
                {{--}--}}
            {{--</script>--}}
        {{--</div>--}}
    </section>
    <!-- Main content -->
    <section class="content">
        <div class="row">
            <div class="col-xs-12">
                <div class="box box-primary">
                    <div class="box-body">
                        <div class="input-group">
                            <form action="/caseList" method="post" enctype="multipart/form-data">
                                {{csrf_field()}}
                                <ul class="setul">
                                    <li>
                                        <select style="width: 150px" class="form-control" name="ind">
                                            <option value="0">请选择行业</option>
                                            @foreach($industry as $i)
                                                <option value="{{ $i['id'] }}">{{ $i['name'] }}</option>
                                            @endforeach
                                        </select>
                                    </li>
                                    <li>
                                        <select style="width: 150px" class="form-control" name="pro">
                                            <option value="0">请选择产品</option>
                                            @foreach($product as $one =>$o)
                                                <option value="1-{{ $o['id'] }}">{{ $o['name'] }}</option>
                                                @foreach($o['two'] as $two => $t)
                                                   <option value="1-{{ $t['id'] }}">&nbsp;&nbsp;&nbsp;&nbsp;▷{{ $t['name'] }}</option>
                                                    @foreach($t['pro'] as $pr => $p)
                                                        <option value="2-{{ $p['id'] }}">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;▶{{ $p['name'] }}</option>
                                                    @endforeach
                                                @endforeach
                                            @endforeach
                                        </select>
                                    </li>
                                    <li>
                                        <select style="width: 100px" name="searchtype" class="form-control" >
                                            @foreach($searchtype as $value)
                                                <option value="{{ $value['id'] }}" @if($value['id'] == 4)selected="selected"@endif>{{ $value['searchtype'] }}</option>
                                            @endforeach
                                        </select>
                                    </li>
                                    <li>
                                        <div class="input-group">
                                            <div class="input-group-addon">
                                                <i class="fa fa-calendar"></i>
                                            </div>
                                            <input style="width: 100px" type="text" class="form-control" name="start_time" id="start_time" placeholder="开始时间">
                                        </div>
                                    </li>
                                    <li>
                                        <div class="input-group">
                                            <div class="input-group-addon">
                                                <i class="fa fa-calendar"></i>
                                            </div>
                                            <input style="width: 100px" type="text" class="form-control" name="end_time" id="end_time" placeholder="结束时间">
                                        </div>
                                    </li>
                                    <li>
                                        <input style="width: 130px;"  name="param" type="text" class="form-control" value="" placeholder="关键字">
                                        <input  type="submit" class="btn btn-info btn-flat" value="Go!">
                                    </li>
                                </ul>
                            </form>
                        </div>
                    </div>
                </div>
                <div class="box">
                    <div class="box-header">
                        <h3 class="box-title">内容</h3>
                        <span style="float:right;color: #bbb">共{{$count}}条结果</span>
                    </div>
                    <!-- /.box-header -->
                    <div class="box-body">
                        <table id="example2" class="table table-bordered table-hover">
                            <thead>
                            <tr>
                                <th style="min-width: 30px">ID</th>
                                <th style="min-width: 50px">权重</th>
                                <th style="min-width: 150px">
                                    更新时间&nbsp;&nbsp;
                                    <a href="/caseList?type={{$search}}&param={{$param}}&orderBy=1"><i class="fa fa-arrow-up"></i></a>&nbsp;&nbsp;
                                    <a href="/caseList?type={{$search}}&param={{$param}}&orderBy=2"><i class="fa fa-arrow-down"></i></a>
                                </th>
                                <th style="min-width: 90px">案例编号</th>
                                <th>案例名</th>
                                <th style="max-width: 80px">行业</th>
                                <th style="min-width: 50px">场景</th>
                                <th style="min-width: 50px">精品</th>
                                {{--<th>类别</th>--}}
                                <th>所属产品</th>
                                <th style="min-width: 70px">设计师</th>
                                <th>价格</th>
                                <th style="min-width: 90px">制作时间</th>
                                <th>制作单位</th>
                                <th>状态</th>
                                <th style="min-width: 90px">图片管理</th>
                                <th style="min-width: 90px">附件管理</th>
                                <th style="min-width: 100px">操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            @foreach($list as $l)
                                <tr>
                                    <td>{{ $l['id'] }}</td>
                                    <td>{{ $l['rank'] }}</td>
                                    <td>{{ $l['update_time'] }}</td>
                                    <td>{{ $l['number'] }}</td>
                                    <td>{{ $l['name'] }}</td>
                                    <td style="max-width: 150px">
                                        <a href="/caseList?searchtype=5&param={{ App\Model\Industry::find($l['industry'])['name'] }}">
                                            {{ App\Model\Industry::find($l['industry'])['name'] }}
                                        </a>
                                    </td>
                                    <td>
                                        @if($l['scene'] === 0)线上
                                        @elseif($l['scene'] === 1)线下
                                        @endif
                                    </td>
                                    <td>
                                        @if($l['lable']==1)精品
                                        @else普通
                                        @endif
                                    </td>
                                    {{--<td>{{ App\Model\ProductCategory::find($l['category'])['name'] }}</td>--}}
                                    <td style="max-width: 200px">
                                        <a href="/caseList?searchtype=8&param={{ App\Model\Product::find($l['product_id'])['name'] }}">
                                            {{ App\Model\Product::find($l['product_id'])['name'] }}
                                        </a>
                                    </td>
                                    <td>{{ App\Model\Designer::find($l['designer'])['name'] }}</td>
                                    <td>{{ $l['price'] }}</td>
                                    <td>{{ $l['make_time'] }}</td>
                                    <td>{{ $l['producer'] }}</td>
                                    <td>
                                        <a href="/caseList?searchtype=100&param={{$l['status']}}">
                                            @if($l['status'] == 0)禁用中
                                            @else已启用
                                            @endif
                                        </a>
                                    </td>
                                    <td> <a class="btn btn-primary btn-xs"  href="{{ url('case/casePicture/'.$l['id']) }}">图片管理<a></td>
                                    <td> <a class="btn btn-primary btn-xs"  href="{{ url('case/caseAnnex/'.$l['id']) }}">附件管理<a></td>
                                    <td>
                                        <a class="btn btn-info btn-xs" href="{{ url('caseShow/'.$l['id']) }}">案例预览</a>
                                        <a class="btn btn-primary btn-xs"  href="{{ url('case/seo/'.$l['id']) }}">设置seo<a>
                                        <a class="btn btn-primary btn-xs"  href="{{ url('caseEdit/'.$l['id']) }}">编辑<a>
                                            {{--<a class="btn btn-danger btn-xs" href="javascript:delCate({{ $c['id'] }})">删除<a>--}}
                                        @if($l['status'] == 1)
                                            <a class="btn btn-warning btn-xs" href="javascript:caseStatus('{{ $l['id'] }}',0)">禁用<a>
                                        @elseif($l['status'] == 0)
                                            <a class="btn btn-success btn-xs" href="javascript:caseStatus('{{ $l['id'] }}',1)">启用<a>
                                        @endif
                                    </td>
                                </tr>
                            @endforeach
                            </tbody>
                        </table>
                    </div>
                    <div style="text-align: center;">
                        {{ $list->appends(['searchtype'=>$search,'param'=>$param,'orderBy'=>$orderBy,'start_time'=>$start_time,'end_time'=>$end_time,'ind'=>$ind,'pro'=>$pro,'count'=>$count])->links() }}
                    </div>
                    <!-- /.box-body -->
                </div>
            </div>
            <!-- /.col -->
        </div>
        <!-- /.row -->
    </section>

@stop

@section('script')
    {{--<script type="text/javascript" src="{{ asset('js/laydate.js') }}"></script>--}}
    <script>
        $(function () {
            //Date picker
            $('#start_time').datepicker({
                format: "yyyy-mm-dd",
                language: "zh-CN",
                autoclose: true
            });
            $('#end_time').datepicker({
                format: "yyyy-mm-dd",
                language: "zh-CN",
                autoclose: true
            });
        });
        //Date picker
//        $('#datepicker').datepicker({
//            autoclose: true,
//            format: 'yyyy-mm-dd'
//        });

        //禁用,启用
        function caseStatus(id,status) {
            $.ajax({
                url: '/caseStatus',
                type: "GET",
                data: {id:id,status:status},
                dataType: "json",
                success: function(res) {
                    console.log(res);
                    if(res.code == 100) {
                        window.location.href=window.location.href;
                        layer.msg(res.msg, {time:1500, icon:6})
                    }
                    else {
                        layer.msg(res.msg, {time:1500, icon:5})
                    }
                }
            });
        }
    </script>
@stop